package com.easyedu.dean.controller;

import com.easyedu.core.util.R;
import com.easyedu.dean.service.EvaluateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 评价算法接口
 *
 * @author mengranliu
 * @date 2022/3/29
 */
@RestController
@RequestMapping("/dean/evaluate/version")
public class EvaluateController {
     private static final Logger LOGGER = LoggerFactory.getLogger(EvaluateController.class);

     private final EvaluateService evaluateService;

     public EvaluateController(EvaluateService evaluateService) {this.evaluateService = evaluateService;}

     /**
      * 计算教室平衡度
      *
      * @param versionId 版本id
      * @return 教室平衡度
      */
     @GetMapping("/balance/classroom")
     public R QueryClassRoomBalance(@RequestParam String versionId) {
          LOGGER.info("versionId 是{}", versionId);
          return R.ok().data(evaluateService.calculateClassRoomBalance(versionId));
     }

     /**
      * 计算学生移动距离
      *
      * @param openYear  开课年
      * @param semester  学期
      * @param versionId 版本id
      * @return 学生移动距离信息
      */
     @GetMapping("/balance/student")
     public R QueryStudentDistance(@RequestParam String versionId) {
          return R.ok().data(evaluateService.calculateStudentDistance(versionId));
     }

     /**
      * 计算课程冲突情况
      * @param versionId 版本
      * @return 返回信息
      */
     @GetMapping("/balance/conflict")
     public R queryConflict(@RequestParam String versionId) {
          return R.ok().data(evaluateService.calculateConflict(versionId));
     }
}
